package com.gitee.wsl.ext.array


/**
 * Flips the elements in the array between the specified indices in place.
 *
 * @param leftIndex The starting index (inclusive) of the portion to flip.
 * @param rightIndex The ending index (inclusive) of the portion to flip.
 */
fun <T> Array<T>.flip(
    leftIndex: Int,
    rightIndex: Int,
) {
    var left = leftIndex
    var right = rightIndex
    while (left <= right) {
        swap(left++, right--)
    }
}